Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp(apps): allow one sided fee middleware handshakes to complete #6253

Merged
merged 10 commits into from
May 7, 2024

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented May 3, 2024

Description

closes: #6171


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Enhanced logging for better visibility during channel operations.
    • Implemented default metadata proposals for invalid counterparty versions in channel handling.
  • Bug Fixes

    • Adjusted fee settings and error handling in middleware to align with received version information.
  • Tests

    • Added new test cases to verify the correct behavior of fee middleware in various scenarios.
    • Updated existing tests to reflect new logic in channel operations.
  • Documentation

    • Updated internal comments and documentation to reflect changes in logic and functionality.

Copy link
Contributor

coderabbitai bot commented May 3, 2024

Walkthrough

The changes in the modules focus on enhancing error handling, logging, and middleware interactions within the IBC framework. These improvements involve refining handshake processes to handle version discrepancies effectively, optimizing middleware operations for better interchain communication, and introducing new test functions to enhance fee management capabilities.

Changes

File Path Change Summary
modules/apps/27-interchain-accounts/host/keeper/handshake.go Added logging and default metadata proposal for invalid counterparty versions.
modules/apps/29-fee/... Improved middleware error handling, introduced functions for fee removal, and added new test cases for fee middleware functionality.
modules/apps/transfer/ibc_module.go Included logging for counterparty version validation in OnChanOpenTry.
testing/endpoint.go Updated handling of ChannelConfig.Version in ChanOpenInit and ChanOpenTry.

Assessment against linked issues

Objective Addressed Explanation
Remove ics4Wrapper field from keepers and adjust IBCMiddleware structure (#3371) The changes in this PR do not directly address the removal of the ics4Wrapper field or the modification of the IBCMiddleware structure as outlined in the linked issue.

Possibly related issues


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

modules/apps/29-fee/fee_test.go Outdated Show resolved Hide resolved
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work as always @srdtrk!

So we can init we a fee version but downgrade/fallback if the counterparty doesn't support 👍🏻

modules/apps/transfer/ibc_module_test.go Outdated Show resolved Hide resolved
modules/apps/transfer/ibc_module.go Outdated Show resolved Hide resolved
Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Thank you, @srdtrk.

return errorsmod.Wrapf(err, "failed to unmarshal ICS29 counterparty version metadata: %s", counterpartyVersion)
// we pass the entire version string onto the underlying application.
// and disable fees for this channel
im.keeper.DeleteFeeEnabled(ctx, portID, channelID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not feeling super strong about it, but we could also alternatively not call SetFeeEnabled in OnChanOpenInit, and call here SetFeeEnabled instead if err == nil.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this since this line is inside the larger im.keeper.IsFeeEnabled(ctx, portID, channelID) if case. This would require a larger refactor.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Out of diff range and nitpick comments (2)
CHANGELOG.md (2)

Line range hint 169-169: Link bare URL to descriptive text
The URL on this line should be linked to descriptive text for better readability and to provide context. For example, [GitHub Pull Request #1234](https://github.com/cosmos/ibc-go/pull/1234).


Line range hint 184-184: Remove trailing spaces
There are unnecessary trailing spaces on this line. It's a good practice to remove trailing spaces as they can complicate version control diffs.

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 474cf93 and 0250262.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional Context Used
Path-based Instructions (1)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0250262 and 817198b.
Files selected for processing (3)
  • modules/apps/29-fee/fee_test.go (2 hunks)
  • modules/apps/transfer/ibc_module.go (1 hunks)
  • modules/apps/transfer/ibc_module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • modules/apps/29-fee/fee_test.go
  • modules/apps/transfer/ibc_module.go
Additional Context Used
Path-based Instructions (1)
modules/apps/transfer/ibc_module_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (3)
modules/apps/transfer/ibc_module_test.go (3)

135-139: Ensure the test case description matches the logic implemented.

Verification successful

The test case description "success: invalid counterparty version proposes new version" is associated with a test function that sets counterpartyVersion to "version" and includes a comment stating "transfer module will propose the default version." This suggests that the test is designed to handle a scenario where an invalid counterparty version triggers the transfer module to propose a default version, which aligns with the description provided.

Given this information, the test case description appears to accurately reflect the logic implemented in the test function. Therefore, the review comment has been verified as accurate.

  • The test function correctly implements the logic described by the test case description.
  • Located in modules/apps/transfer/ibc_module_test.go.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the test case description "success: invalid counterparty version proposes new version" accurately reflects the test logic.

# Test: Search for the test case description in the codebase. Expect: Description should match the logic.
rg --type go $'success: invalid counterparty version proposes new version'

Length of output: 190



Script:

#!/bin/bash
# Description: Examine the test function logic associated with the description "success: invalid counterparty version proposes new version" to ensure it matches the description.

# Test: Extract the full test function to analyze the logic implemented.
rg --type go -A 10 $'success: invalid counterparty version proposes new version' modules/apps/transfer/ibc_module_test.go

Length of output: 486


141-146: Ensure error handling is robust in test cases.

Verification successful

The verification script has confirmed the presence of the test case "failure: max channels reached" in the ibc_module_test.go file. However, the script only checked for the existence of the test case description and did not delve into the specifics of the error handling mechanisms implemented within the test case. This means we do not have enough information to fully verify the robustness of the error handling as mentioned in the review comment.

To proceed, we need to examine the implementation details of this specific test case to ensure that it covers all necessary scenarios as expected. This involves checking the logic within the test case to see if it appropriately triggers and handles the types.ErrMaxTransferChannels error.


The script output provides the implementation details for the test case "failure: max channels reached". The test case sets the ChannelID to a value beyond the maximum allowed (math.MaxUint32 + 1) and expects the error types.ErrMaxTransferChannels to be triggered. This indicates that the test case is specifically designed to test the scenario where the maximum number of transfer channels is exceeded, and it correctly anticipates the corresponding error.

Given this information, it appears that the error handling for this specific test case is implemented as expected, focusing on the scenario of exceeding the maximum channel limit and checking for the correct error response.

Conclusion:
The error handling in the test case "failure: max channels reached" is robust and correctly implemented to cover the scenario of exceeding the maximum number of transfer channels.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the error handling in the test case "failure: max channels reached" is robust and covers all necessary scenarios.

# Test: Search for the test case in the codebase. Expect: Comprehensive error handling.
rg --type go $'failure: max channels reached'

Length of output: 132



Script:

#!/bin/bash
# Description: Examine the implementation details of the test case "failure: max channels reached" to ensure it appropriately handles the types.ErrMaxTransferChannels error.

# Test: Extract the implementation details of the test case from the codebase.
rg --type go -A 10 $'failure: max channels reached' modules/apps/transfer/ibc_module_test.go

Length of output: 603


152-157: Check for consistency in error messages and handling.

Verification successful

The verification script was executed to check the consistency of error handling in the test case "failure: invalid order - ORDERED" within the ibc_module_test.go file. The script successfully located the specific test case in the codebase, confirming its presence.

However, the script output does not provide detailed information about how the error is handled or whether the error handling is consistent with the module's standards. To fully address the review comment, we need to examine the implementation details of the error handling in this test case and compare it with the standard error handling practices in the module.

Since the current script output is insufficient for a conclusive verification, further investigation is required.


The additional script output has provided the necessary context to evaluate the error handling for the test case "failure: invalid order - ORDERED" in the ibc_module_test.go file. The test case explicitly sets the channel ordering to channeltypes.ORDERED and expects an error channeltypes.ErrInvalidChannelOrdering to be triggered.

This setup indicates that the test is designed to validate that the system correctly identifies and handles an invalid channel ordering scenario, which is consistent with the module's standards for error handling. The error type ErrInvalidChannelOrdering is appropriately used here to indicate the specific nature of the error, aligning with the expected module behavior.

Given this information, it can be concluded that the error handling in this test case is consistent with the module's standards.

  • The test case correctly sets up a scenario for an invalid channel order.
  • It checks for the specific error channeltypes.ErrInvalidChannelOrdering, which is appropriate for this kind of failure.

This confirms that the error handling is implemented correctly and consistently within the module's standards.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the error messages and handling in the test case "failure: invalid order - ORDERED" are consistent with the module's standards.

# Test: Search for the test case in the codebase. Expect: Consistent error handling.
rg --type go $'failure: invalid order - ORDERED'

Length of output: 138



Script:

#!/bin/bash
# Description: Examine the error handling details for the test case "failure: invalid order - ORDERED" in ibc_module_test.go

# Extract the relevant test case block and check for error handling consistency.
rg --type go -A 10 'failure: invalid order - ORDERED' modules/apps/transfer/ibc_module_test.go

Length of output: 386

Copy link

sonarcloud bot commented May 7, 2024

Quality Gate Passed Quality Gate passed for 'ibc-go'

Issues
9 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@srdtrk srdtrk merged commit 3b3ecc5 into main May 7, 2024
78 checks passed
@srdtrk srdtrk deleted the serdar/6171-one-sided-fee branch May 7, 2024 03:55
mergify bot pushed a commit that referenced this pull request May 7, 2024
* imp: added counter version proposal to try step

* test: fixed tests

* test: tested removing fee middleware

* test: added ica onesided test

* add changelog

* imp: improved RemoveFeeMiddleware

* nit: damian

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit 3b3ecc5)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/handshake.go
#	modules/apps/29-fee/fee_test.go
#	modules/apps/29-fee/ibc_middleware.go
#	modules/apps/29-fee/transfer_test.go
#	modules/apps/transfer/ibc_module.go
#	modules/apps/transfer/ibc_module_test.go
mergify bot pushed a commit that referenced this pull request May 7, 2024
* imp: added counter version proposal to try step

* test: fixed tests

* test: tested removing fee middleware

* test: added ica onesided test

* add changelog

* imp: improved RemoveFeeMiddleware

* nit: damian

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit 3b3ecc5)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/transfer/ibc_module_test.go
crodriguezvega added a commit that referenced this pull request May 7, 2024
…kport #6253) (#6260)

* imp(apps): allow one sided fee middleware handshakes to complete (#6253)

* imp: added counter version proposal to try step

* test: fixed tests

* test: tested removing fee middleware

* test: added ica onesided test

* add changelog

* imp: improved RemoveFeeMiddleware

* nit: damian

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit 3b3ecc5)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/handshake.go
#	modules/apps/29-fee/fee_test.go
#	modules/apps/29-fee/ibc_middleware.go
#	modules/apps/29-fee/transfer_test.go
#	modules/apps/transfer/ibc_module.go
#	modules/apps/transfer/ibc_module_test.go

* imp: iteration one

* imp: iteration two

* Update CHANGELOG.md

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
crodriguezvega added a commit that referenced this pull request May 8, 2024
…kport #6253) (#6261)

* imp(apps): allow one sided fee middleware handshakes to complete (#6253)

* imp: added counter version proposal to try step

* test: fixed tests

* test: tested removing fee middleware

* test: added ica onesided test

* add changelog

* imp: improved RemoveFeeMiddleware

* nit: damian

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit 3b3ecc5)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/transfer/ibc_module_test.go

* imp: first iteration

* fix: test

* nit

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Channel handshake failure with one-sided fee middleware on empty version string
3 participants